Skip to content

chore(test): add stack lifecycle events screen test with scenario#4305

Open
LKuchno wants to merge 12 commits into
mainfrom
@lkuchno/test-stack-lifecycle-events
Open

chore(test): add stack lifecycle events screen test with scenario#4305
LKuchno wants to merge 12 commits into
mainfrom
@lkuchno/test-stack-lifecycle-events

Conversation

@LKuchno

@LKuchno LKuchno commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Description

Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1607

Adds a new single-feature test screen exercising the gamma StackContainer screen lifecycle callbacks — onWillAppear, onDidAppear, onWillDisappear, onDidDisappear — across push, pop, and a nested stack. It mirrors the existing test-tabs-lifecycle-events screen so stack and tabs lifecycle behaviour can be checked with the same toast-based visualization.

Each transition pushes a color-coded toast (onWillAppear - green, onWillDisappear - light navy, onDidAppear - light blue, onDidDisappear — dark navy) so the fired events and their order are visible on device.

Changes

  • test-stack-lifecycle-events/index.tsx — test screen: an outer stack (Home → A → NestedStack) and a nested stack (NestedHome → NestedA). A shared useMakeLifecycleCallbacks hook attaches the four lifecycle callbacks to every route. Every route sets a header title; the NestedStack route's header is intentionally shown, so on iOS the outer NestedStack header and the inner nested-stack header stack together — letting the scenario exercise popping the whole container via the outer NestedStack header back button as well as the inner one.
  • test-stack-lifecycle-events/scenario.md — manual scenario covering push/pop (Pop button / header back button / native gesture / system back) at the top level and inside the nested stack, plus crossing the nested-stack boundary — popping the whole container back to Home from both NestedHome and NestedA via the outer NestedStack header back button. Documents per-platform event orderings, including the iOS outer-first vs Android inner-first difference on the container pop.
  • test-stack-lifecycle-events/scenario-description.ts — scenario metadata (e2eCoverage: 'tbd', platforms iOS + Android).
  • stack-v5/index.ts — registers the scenario in the Stack v5 group.

Note:

This test will have to be updated if https://github.com/software-mansion/react-native-screens-labs/issues/1649 is fixed, and the changes mentioned by @kligarski in #4305 (comment) are implemented.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Stack v5 single-feature test screen to manually verify gamma StackContainer lifecycle callbacks (onWillAppear, onDidAppear, onWillDisappear, onDidDisappear) across push/pop flows, including a nested stack, using toast messages to visualize event order.

Changes:

  • Introduces a new “Stack lifecycle events” scenario screen that triggers toast notifications from lifecycle callbacks for each route (outer + nested stack).
  • Adds a detailed manual test scenario (scenario.md) documenting expected event sequences per platform and per navigation method.
  • Registers the new scenario in the Stack v5 scenario group.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
apps/src/tests/single-feature-tests/stack-v5/test-stack-lifecycle-events/scenario.md New manual scenario documenting expected lifecycle event ordering for push/pop and nested stack flows.
apps/src/tests/single-feature-tests/stack-v5/test-stack-lifecycle-events/scenario-description.ts Adds scenario metadata (name/key/details/platforms/e2eCoverage).
apps/src/tests/single-feature-tests/stack-v5/test-stack-lifecycle-events/index.tsx Implements the new test screen with outer + nested StackContainer and toast-based lifecycle callbacks.
apps/src/tests/single-feature-tests/stack-v5/index.ts Registers and exports the new Stack v5 scenario so it appears in the scenario group/menu.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

LKuchno and others added 3 commits July 9, 2026 13:50
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@LKuchno LKuchno marked this pull request as draft July 9, 2026 13:46
LKuchno added 2 commits July 10, 2026 10:18
…tware-mansion/react-native-screens into @lkuchno/test-stack-lifecycle-events
@LKuchno LKuchno added the area:stack-v5 Issues related to Native Stack v5 implementation label Jul 10, 2026
@LKuchno LKuchno changed the title test: add stack lifecycle events single-feature test chore(test): add stack lifecycle events screen test with scenario Jul 10, 2026
LKuchno added 2 commits July 10, 2026 12:08
…ps to confim pop/push events for nested stacks
…on iOS on this screen two headers are visible
@LKuchno LKuchno marked this pull request as ready for review July 13, 2026 07:26
@LKuchno LKuchno requested review from kkafar and kligarski July 13, 2026 07:29
Comment on lines +51 to +56
**Android** — only the screen entering or leaving the stack fires; the
screen underneath stays silent:
- **Push (Y pushed over X):** only the pushed screen fires —
`Y: onWillAppear`, then `Y: onDidAppear`. X fires nothing.
- **Pop (Y popped, back to X):** only the popped screen fires —
`Y: onWillDisappear`, then `Y: onDidDisappear`. X fires nothing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should change soon when we handle detach and attach in fragment manager. Not sure if we should merge the test in its current form or wait for the changes?

cc @kkafar

@LKuchno LKuchno requested a review from kligarski July 14, 2026 08:05
…ns into @lkuchno/test-stack-lifecycle-events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:stack-v5 Issues related to Native Stack v5 implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants